package com.fourth.fronted.controller;

import com.fourth.entity.CartItem;
import com.fourth.fronted.service.CartItemService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/front")
public class CartItemController {

    @Resource
    private CartItemService cartItemService;

    @Resource
    HttpSession httpSession;

    /**
     * 根据uId获取所有的商品信息
     * @return
     */
    @RequestMapping("/selectCartItemByUid")
    List<CartItem> selectCartItemByUid() {

        //httpSession.setAttribute("uId",12);
        Integer uid = (Integer)httpSession.getAttribute("uId");
        System.out.println("uid:" + uid);
        return cartItemService.selectCartItemByUid(uid);
    }
}
